home *** CD-ROM | disk | FTP | other *** search
- Path: beach.and.nl!usenet
- From: jos@and.nl (Jos A. Horsmeier)
- Newsgroups: comp.lang.c
- Subject: Re: Logical exclusive-or
- Date: 6 Feb 1996 09:15:52 GMT
- Organization: AND Operations Research B.V.
- Message-ID: <4f7688$4te@beach.and.nl>
- References: <4f6lrq$bcr@lastactionhero.rs.itd.umich.edu>
- NNTP-Posting-Host: klepzeiker.and.nl
- Mime-Version: 1.0
- Content-Type: Text/Plain; charset=ISO-8859-1
- X-Newsreader: WinVN 0.99.5
-
- In article <4f6lrq$bcr@lastactionhero.rs.itd.umich.edu>, davidm@umich.edu
- wrote:
-
- |Is there a good reason why C doesn't have a logical exclusive-or
- |operator? A look at the precedence hierarchy suggests an obvious
- |symbol and precedence for such an operator:
- |
- | bitwise and &
- | bitwise exclusive or ^
- | bitwise inclusive or |
- | logical and &&
- | logical or ||
- |
- |The logical exclusive or would be represented by ^^ and have
- |precedence higher than || but lower than && . If C requires machines
- |to be able to implement bitwise XOR, then it would seem reasonable to
- |require the logical operator also.
-
- Note that although the logical 'and' and 'or' operators do not
- evaluate their right operand if their left operand is false or
- true resepectively, the 'logical exclusive or' operator must
- evaluate both operands no matter what the value of the left hand
- operand is. So the sole purpose of a '^^' operator would be a lexical
- shorthand for:
-
- a ^^ b == (!(a) != !(b))
-
- That wouldn't be much of added functionality, would it?
-
- kind regards,
-
- Jos aka jos@and.nl
- --
- Atnwgqkrl gy zit vgksr, ug qshiqwtzoeqs!
-
-